<template>
	<view class="container">
		<u-navbar :background="{ background: '#6EC9E1' }" :is-fixed="true" z-index='999' :border-bottom="false"
			title-color="#FFF" back-icon-color="#FFF">
		</u-navbar>

		<view class="main">
			<view class="title">
				<text>{{info.status_text}}</text>
				<view class="fts2">
					<span class="times">有效期</span>
					{{info.start_time+'~'+ info.end_time}}
				</view>
			</view>
			<view class="card" v-if="user.job==2" @click="goTo('/sub/center/mine/userInfo?id='+info.user_id)">
				<view class="left">
					<u-avatar mode="square" :src="info.user_info.avatar"></u-avatar>
					<view style="margin-left: 16rpx;">
						<p class="ftw">{{info.user_info.username}}</p>
					</view>
				</view>
				<view class="right">
					<u-icon name="arrow-right" color="#7c7c7c" size="26"></u-icon>
				</view>
			</view>
			<view class="card" v-else>
				<view class="left">
					<u-avatar mode="square" :src="info.doctor_info.avatar"></u-avatar>
					<view style="margin-left: 16rpx;">
						<p class="ftw fts3">{{info.doctor_info.username}}</p>
						<p>{{info.doctor_info.speciality}}</p>
					</view>
				</view>
				<view class="right">
					<view class="toChat" @click="tochat(info.doctor_id)">聊天</view>
				</view>
			</view>

			<view class="content">
				<view class="c1">
					<span class="ftw fts1">感谢礼品</span>
					<span class="fts2">{{info.goods_name+' x'}}{{info.num||0}}</span>
				</view>
				<u-line></u-line>

				<view class="c1">
					<span class="ftw fts1">回馈服务</span>
					<span class="fts2">{{info.msg}}</span>
				</view>
				<u-line></u-line>

				<view class="c1">
					<span class="ftw fts1">支付金额</span>
					<span class="fts2">￥{{info.pay||'0'}}</span>
				</view>
			</view>

			<view class="content">
				<view class="c2 c1">
					<span class="ftw fts3">绑定成员</span>
					<span>{{info.bind_num||0}}/{{info.people ||0}}</span>
				</view>

				<view class="item" v-for="(item,index) in info.member_info" :key="index">
					<view class="c2">
						<view class="left">
							<view class="avatar">
								{{item.username.substring(0,1)}}
							</view>
							<view class="user">
								<view class="info">
									<span class="name">{{item.username}}</span>
									<span class="age">{{item.age}}</span>
									<span class="sex">{{item.gender_text||'--'}}</span>
								</view>
								<view class="info fts2">
									<span>联系电话</span>
									<span>{{item.mobile||''}}</span>
								</view>
							</view>
						</view>

					</view>
				</view>

				<view class="button" @click="goTo('/sub/center/mine/binding_member?id='+info.id)"
					v-if="info.bind_num<info.people">
					<u-icon name="plus" color="#6EC9E1" size="26" bold="true"></u-icon>
					<span>绑定成员</span>
				</view>

			</view>

			<view class="content">
				<view class="c2 c1">
					<span class="ftw fts3">订单信息</span>
				</view>

				<view class="c2 c1">
					<view class="">
						<span class="ftw fts2">订单编号：</span>
					</view>
					<view class="">
						<span class="ftw fts2">{{info.order_sn || ''}}</span>
					</view>
				</view>
				<view class="c2 c1">
					<view class="">
						<span class="ftw fts2">创建时间：</span>
					</view>
					<view class="">
						<span class="ftw fts2">{{info.createtime|| ''}}</span>
					</view>
				</view>
			</view>

		</view>
		<!-- 提示 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		bindMemberDetail,
		chat
	} from '@/api/index.js'
	export default {
		data() {
			return {
				info: {},
				id: 0,
				user: {}
			}
		},
		onLoad(e) {
			this.id = e.id
			this.init(e.id)
		},
		onShow() {
			this.init(this.id)
		},
		methods: {
			init(id) {
				let that = this
				that.user = that.ws.getUserInfo()
				bindMemberDetail({
					'id': id
				}).then(res => {
					if (res.code == 1) {
						that.info = res.data.detail
					} else {
						that.$refs.uToast.show({
							title: res.msg
						})
					}
				})
			},
			goTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			tochat(id) {
				let that = this
				chat({
					'user_id': id
				}).then(res => {
					if (res.code == 1) {
						that.ws.tochat(res.data.session_id)
					}
				})
			},
		}

	}
</script>

<style lang="less">
	.container {
		background: url('@/static/img/mine/header-bg.png');
		background-size: 100% 26vh;
		background-repeat: no-repeat;
		background-color: #EEE;
		height: 100vh;

		.avatar {
			background-color: #6EC9E1;
			text-align: center;
			height: 43px;
			width: 43px;
			color: #FFF;
			line-height: 43px;
			border-radius: 50%;
		}

		.main {
			padding: 0 30rpx;

			.button {
				display: flex;
				justify-content: center;
				align-items: center;
				border: 1px #6EC9E1 solid;
				color: #6EC9E1;
				background-color: #FFF;
				border-radius: 10rpx;
				padding: 20rpx;
				margin-top: 40rpx;

				span {
					border: unset;
				}
			}

			.ftw {
				font-weight: bold;
			}

			.fts1 {
				font-size: 30rpx;
			}

			.fts3 {
				font-size: 16px;
			}

			.fts2 {
				font-size: 13px;
				opacity: 0.8;
			}


			.left {
				display: flex;
				align-items: center;

				.user {
					.info {
						padding: 10rpx 0;

						span {
							opacity: 0.8;
							font-size: 14px;
							margin: 0 10rpx;
						}

						.name {
							opacity: 1;
							font-size: 16px;
						}

						.age,
						.sex {
							color: #6EC9E1;
							padding: 4rpx 8rpx;
							border-radius: 8rpx;
							background-color: rgba(229, 229, 229, 0.5);
						}
					}
				}
			}

			.title {
				color: #FFF;
				text-align: center;

				text {
					font-size: 24px;
				}

				view {
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.times {
					color: #6EC9E1;
					border-radius: 30rpx;
					padding: 2rpx 10rpx;
					margin-right: 10rpx;
					background-color: #EAF5F7;
				}
			}

			.content {
				margin-top: 20rpx;
				background-color: #FFF;
				border-radius: 20rpx;
				padding: 30rpx;

				.c1 {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 30rpx 0;
				}

				.c2 {
					display: flex;
					align-items: center;
					padding: 10rpx 0;
				}
			}

			.card {
				margin-top: 20rpx;
				background-color: #FFF;
				border-radius: 20rpx;
				padding: 40rpx 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.toChat {
					color: #6EC9E1;
					background-color: #EAF5F7;
					border-radius: 30rpx;
					padding: 10rpx 40rpx;
				}

			}
		}

	}
</style>